; NLS
;
; GENERAL PURPOSE EQUATES
;
FORASAV  EPZ 0
FORXSAV  EPZ FORASAV+1
FORYSAV  EPZ FORXSAV+1
FORZPG   EPZ FORYSAV+1
DESTADR  EPZ FORZPG+2
PTRADR   EPZ DESTADR+2
ISIMMED  EPZ PTRADR+2
OP       EPZ ISIMMED+1
MAXLEN   EPZ OP+2
VALUE    EPZ MAXLEN+1
DIGIT    EPZ VALUE+2
LEAD0    EPZ DIGIT+1
JMPADR   EPZ LEAD0+1
COUNT    EPZ JMPADR+2
GOTLN    EPZ COUNT+1
LINEINDX EPZ GOTLN+1
SIGN     EPZ LINEINDX+1
ACL      EPZ SIGN+1
ACH      EPZ ACL+1
XTNDL    EPZ ACH+1
XTNDH    EPZ XTNDL+1
AUXL     EPZ XTNDH+1
AUXH     EPZ AUXL+1
;
PROMPT   EPZ $33
RNDL     EPZ $4E
RNDH     EPZ $4F
STACK    EQU $100
INPUT    EQU $200
;
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
;
;
; "IF" STATEMENT EQUATES
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
; SPEED/ASM ENTRY POINTS
;
;
;
; NOTE: THE EQUATE OF PUTC MUST
; BE CHANGED IF YOU RELOCATE
; SPEED/ASM TO SOME LOCATION
; OTHER THAN $7800
;
PUTC     EQU $7000
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ;FOR USE BY S/A ONLY- SEE DOC.
SAPC     EQU SAGL+3          ; "   "   "  "   "     "   "
HOME     EQU SAPC+3          ;HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
ONXGOTO  EQU RDINT+3
CASE     EQU ONXGOTO+3
CASEI    EQU CASE+3
INSET    EQU CASEI+3
NOTINSET EQU INSET+3
ABS      EQU NOTINSET+3
NEG      EQU ABS+3
MUL      EQU NEG+3
DIV      EQU MUL+3
MOD      EQU DIV+3
RND      EQU MOD+3
SUBSTR   EQU RND+3
INDEX    EQU SUBSTR+3
LENGTH   EQU INDEX+3
CONCAT   EQU LENGTH+3
GETWZPG  EQU CONCAT+3        ;USED BY SPEED/ASM
RDFP     EQU GETWZPG+3
PRTE     EQU RDFP+3
PRTF     EQU PRTE+3
FADD     EQU PRTF+3
FSUB     EQU FADD+3
FMUL     EQU FSUB+3
FDIV     EQU FMUL+3
FLT      EQU FDIV+3
FIX      EQU FLT+3
FNEG     EQU FIX+3
FADDTN   EQU FNEG+3
FSUBTN   EQU FADDTN+3
FTIMES   EQU FSUBTN+3
FINTO    EQU FTIMES+3
IFF      EQU FINTO+3
MOVFP    EQU IFF+3
;
;
         JSR INIT
         JSR HOME
         JSR PRINT
         BYT "Testing the FIX, FLT, FNEG, MOVF,",CR
         BYT "and IFF routines:",CR,CR
         BYT CR,"Initializing...  Please wait",CR,CR,0
;
         LDY #0
MOVFSTR  LDA FSTRS,Y
         STA INPUT,Y
         INY 
         BNE MOVFSTR
;
         LDX #0
         STX LINEINDX
         INX 
         STX GOTLN
;
         JSR RDFP
         ADR F6
;
         JSR RDFP
         ADR F5
;
         JSR RDFP
         ADR F4
;
         JSR RDFP
         ADR F0.6
;
         JSR RDFP
         ADR F0.5
;
         JSR RDFP
         ADR F0.4
;
         JSR RDFP
         ADR F0
;
         JSR RDFP
         ADR FM0.4
;
         JSR RDFP
         ADR FM0.5
;
         JSR RDFP
         ADR FM0.6
;
         JSR RDFP
         ADR FM4
;
         JSR RDFP
         ADR FM5
;
         JSR RDFP
         ADR FM6
;
         JSR RDFP
         ADR F1E37
;
         JSR RDFP
         ADR FM1E37
;
         JSR RDFP
         ADR F1EM37
;
         JSR RDFP
         ADR FM1EM37
;
         JSR GETRTN
;
         JSR PRINT
         BYT "Testing the IFF statement:",CR,CR
;
         BYT "Testing equality",CR,0
;
; TEST EQUALITY
;
         LDA #0
         STA OPERATOR
         JSR DOTEST
;
         LDA #1
         STA OPERATOR
         JSR PRINT
         BYT "Testing inequality:",CR,0
         JSR DOTEST
;
         LDA #2
         STA OPERATOR
         JSR PRINT
         BYT "Testing greater than:",CR,0
         JSR DOTEST
;
         LDA #3
         STA OPERATOR
         JSR PRINT
         BYT "Testing less than:",CR,0
         JSR DOTEST
;
         LDA #4
         STA OPERATOR
         JSR PRINT
         BYT "Testing greater than or equal:",CR,0
         JSR DOTEST
;
         LDA #5
         STA OPERATOR
         JSR PRINT
         BYT "Testing less than or equal:",CR,0
         JSR DOTEST
;
;
         JSR PRINT
         BYT CR,"Testing MOVF:",CR,CR
         BYT "FVAR=0.5;",CR
         BYT "FVAR0=FVAR;",CR
         BYT "FVAR0= ",0
         JSR MOVFP
         ADR F0.5,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR GETRTN
         JSR PRINT
         BYT CR,CR,CR
         BYT "Testing FIX:",CR
         BYT "IVAR=FIX(0.5);",CR
         BYT "IVAR= ",0
         JSR FIX
         ADR F0.5,IVAR
         JSR PRTINT
         ADR IVAR
;
         JSR PRINT
         BYT CR,"IVAR=FIX(6);",CR
         BYT "IVAR= ",0
         JSR FIX
         ADR F6,IVAR
         JSR PRTINT
         ADR IVAR
;
         JSR PRINT
         BYT CR,CR
         BYT "Testing FLT:",CR,CR
         BYT "FVAR=FLT(21);",CR
         BYT "FVAR= ",0
         JSR LOAD
         ADR 21,IVAR
         JSR FLT
         ADR IVAR,FVAR
         JSR PRTF
         ADR FVAR
;
         JSR PRINT
         BYT CR,CR,CR
         BYT "Testing FNEG:",CR,CR
         BYT "FVAR=FNEG(21);",CR
         BYT "FVAR= ",0
         JSR FNEG
         ADR FVAR
         JSR PRTF
         ADR FVAR
         JSR GETRTN
;
         JSR PRINT
         BYT CR,CR,CR
         BYT "That's all folks...",CR,CR,0
         BRK 
;
;
;
;
;
;
;
DOTEST:
         LDA #0
         STA INDEX0
         STA INDEX1
;
CMPLOOP  LDX INDEX1
         LDY FVARS,X
         LDX INDEX0
         LDA FVARS,X
         JSR TSTIF
         INC INDEX0
         LDA INDEX0
         CMP #17
         BLT CMPLOOP
         JSR GETRTN
         LDA #0
         STA INDEX0
         INC INDEX1
         LDA INDEX1
         CMP #17
         BLT CMPLOOP
         RTS 
;
;
;
;
TSTIF:
         PHA 
         LDX #0
YLOOP    LDA FPAG,Y
         STA FVAR0,X
         INY 
         INX 
         CPX #8
         BLT YLOOP
;
         PLA 
         TAX 
         LDY #0
XLOOP    LDA FPAG,X
         STA FVAR1,Y
         INX 
         INY 
         CPY #8
         BLT XLOOP
;
         JSR PRINT
         BYT "Is ",0
         JSR PRTF
         ADR FVAR0
         LDA #" "
         JSR PUTC
         LDA OPERATOR
         BEQ ISEQLS
         SEC 
         SBC #2
         BMI ISNOTEQL
         BEQ ISGT
         SEC 
         SBC #2
         BMI ISLT
         BEQ ISGE
;
         JSR PRINT
         BYT "<=",0
         JMP >0
;
ISLT     LDA #"<"
         JSR PUTC
         JMP >0
;
ISGE     JSR PRINT
         BYT ">=",0
         JMP >0
;
ISGT     LDA #">"
         JSR PUTC
         JMP >0
;
ISNOTEQL JSR PRINT
         BYT "<>",0
         JMP >0
;
ISEQLS   LDA #"="
         JSR PUTC
;
^0       LDA #" "
         JSR PUTC
         JSR PRTF
         ADR FVAR1
         JSR PRINT
         BYT " ? ",0
;
         LDX OPERATOR
         BEQ DOEQL
         DEX 
         BEQ DONOTEQL
         DEX 
         BEQ DOGT
         DEX 
         BEQ DOLT
         DEX 
         BEQ DOGE
;
         JSR IFF
         ADR FVAR0,LE,FVAR1
         JMP DOBOOL
;
DOGE     JSR IFF
         ADR FVAR0,GE,FVAR1
         JMP DOBOOL
;
DOLT     JSR IFF
         ADR FVAR0,LT,FVAR1
         JMP DOBOOL
;
DOGT     JSR IFF
         ADR FVAR0,GT,FVAR1
         JMP DOBOOL
;
DONOTEQL JSR IFF
         ADR FVAR0,NE,FVAR1
         JMP DOBOOL
;
DOEQL    JSR IFF
         ADR FVAR0,EQ,FVAR1
;
DOBOOL   BTR >0
         JSR PRINT
         BYT "NO!",CR,0
         RTS 
;
^0       JSR PRINT
         BYT "YES!",CR,0
         RTS 
;
;
;
;
;
YESORNO  BTR >0
         JSR PRINT
         BYT "NO!",CR,CR,0
         RTS 
;
^0       JSR PRINT
         BYT "YES!",CR,CR,0
         RTS 
;
;
;
;
GETRTN   JSR PRINT
         BYT CR,CR,"(Press return to continue):",0
         JSR READLN
         JMP HOME
;
;
;
;
;
HERE     EQU *&$FF00
THERE    EQU $FF00&*+136
         .IF HERE#THERE
         DFS 256-*&$FF
         .FI 
;
FPAG     EQU *&$FF00
F6       DFS 8,0
F5       DFS 8,0
F4       DFS 8,0
F0.6     DFS 8,0
F0.5     DFS 8,0
F0.4     DFS 8,0
F0       DFS 8,0
FM0.4    DFS 8,0
FM0.5    DFS 8,0
FM0.6    DFS 8,0
FM4      DFS 8,0
FM5      DFS 8,0
FM6      DFS 8,0
F1E37    DFS 8,0
FM1E37   DFS 8,0
F1EM37   DFS 8,0
FM1EM37  DFS 8,0
FVAR0    DFS 8,0
FVAR1    DFS 8,0
OPERATOR DFS 1
INDEX0   DFS 1
INDEX1   DFS 1
FVAR     DFS 8,0
IVAR     DFS 2,0
;
;
FVARS:
         BYT F6,F5,F4,F0.6,F0.5,F0.4,F0
         BYT FM0.4,FM0.5,FM0.6,FM4,FM5
         BYT FM6,F1E37,FM1E37,F1EM37
         BYT FM1EM37
;
;
FSTRS    BYT "6,5,4,.6,.5,.4,0,-.4,-.5,-.6"
         BYT " -4,-5,-6,1E37,-1E37,1E-37,-1E-37",CR,0
;
         END